<template>
	<div class="port-page">
		<!-- 顶部按钮 -->
		<div class="but1">
			<router-link to="/home">
				<el-button type="warning" size="small" class="add btn" style='margin-right: 10px;' icon="el-icon-menu">首页</el-button>
			</router-link>
		</div>
		<!-- 模糊搜索条件 -->
		<!--<div style="width: 100%;text-align: center;font-size: 30px;float: left;margin-top: 20%;color: red;">-->
		<div id="zctj" style="width: 100%;height: 400px;margin-top: 50px;"></div>
		<!--</div>-->
		<LoadingComponent v-show="isLoading"></LoadingComponent>
		<router-view class="port-view"></router-view>
	</div>
</template>
<script>
	import { mapState } from 'vuex'
	import LoadingComponent from 'components/loading'
	import echarts from 'echarts'
	import qs from 'qs'
	export default {
		props: ['params'],
		components: {
			LoadingComponent,
		},
		data() {
			return {
				url1:'',
				cqv: [],
				sj: [],
				add: [],
				multipleDelNum: '', //获取批量选择的数据
				dataList: [], //表格数据
				comboxlist: [], //下拉框 动态的
				/*动画加载*/
				isLoading: true, //动画加载
				searchLoading: false, //搜索按钮触发按钮动画
				/*分页属性设置*/
				layout: 'total, sizes, prev, pager, next, jumper', //组件布局
				pageindex: this.$store.state.pageindex, //当前分页页码
				pagesizes: this.$store.state.pagesizes, //显示个数的选择器选项
				pagesize: this.$store.state.pagesize, //每页显示条目数
				total: 0, //总条数

				/*组件区域*/

				/*
				    prop :  接口参数名
				    label : 接口中文名
				    hide : 是否隐藏这一列
				    align : 这一列对齐顺序 ： left,right,center
				    headerAlign : 这一列表头对齐方式 ： left,right,center
				*/

			}
		},
		created() {
			//权限
		
			var logininfo = JSON.parse(localStorage.logininfo);
			//加载页面时调用
			this.$store.dispatch('changeTitle', '支出统计'); //修改title
			this.$store.dispatch('changeRouterIndex', '/statistics/zctj'); //修改路由
			this.search(); //分页获取默认数据
			this.isLoading = true; //动画开始

		},
		mounted() {
			//加载完成之后event
			this.isLoading = false; //动画结束
		},
		methods: {
			
			drawPie2(id, lststr) {
				this.charts = echarts.init(document.getElementById(id))
				this.charts.setOption({
					title: {
						text: '支出统计',
						left: 'center'
					},

					tooltip: {
						trigger: 'item',
						formatter: "{b} : {c} ({d}%)"
					},
					legend: {
						// orient: 'vertical',
						// top: 'middle',
						bottom: 10,
						left: 'center',
						data: ['西凉', '益州', '兖州', '荆州', '幽州']
					},
					series: [{
						type: 'pie',
						radius: '65%',
						center: ['50%', '50%'],
						selectedMode: 'single',
						data: this.add,
						itemStyle: {
							emphasis: {
								shadowBlur: 10,
								shadowOffsetX: 0,
								shadowColor: 'rgba(0, 0, 0, 0.5)'
							}
						}
					}]
				})
			},
			search() {
				//查询搜索触发事件
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					day: 1,
					code: 'zcje',
					lsid: '',
					bjtime: '',
					edtime: '',
					yhid: logininfo.id,
					xxid: logininfo.xxid,
				});
				this.searchLoading = true;
				this.axios.post(this.$store.state.api + 'ls/getlstj', params3)
					.then(res => {
						console.log(list1, 999988887777)
						var list1 = res.data.data.lsit
						this.add = list1
						this.$nextTick(function() {
							this.drawPie2('zctj')
						});
						this.searchLoading = false;
					}).catch(res => {
						console.log(res)
						this.searchLoading = false;
					})
			},

			/* 组件的弹框  */
			componentsShow(type, data) { //显示组件
				for(let i in this.portComponents) {
					if(type == this.portComponents[i].type) {
						this.portComponents[i].toggle = true;
						this.portComponents[i].params = data;
						if(this.portComponents[i].data.type == 'single') {
							this.portComponents[i].data.index = data.row.id
						} else if(this.portComponents[i].data.type == 'multiple') {
							this.portComponents[i].data.index = this.multipleDelNum;
						} else {
							return;
						}
						return;
					}
				}
			},
			componentsHide(setting) { //关闭组件
				for(let i in this.portComponents) {
					if(setting.type == this.portComponents[i].type) {
						this.portComponents[i].toggle = false;
						if(!setting.cancel) {
							this.search();
						}
						return;
					}
				}
			}
		},
		computed: {
			...mapState([
				'api' //域名
			]),
			multipleDeleteDisabled() {
				// console.log(this.multipleDelNum)
				if(this.multipleDelNum) {
					return false;
				} else {
					return true
				}
			}
		}
	}
</script>

<style lang="less" scoped>
	.port-page {
		font-size: 12px;
		.btn {
			height: 30px;
			padding: 0 10px;
		}
		.code-search {
			height: 30px;
			margin: 10px 0 10px 0;
			min-width: 100px;
			max-width: 135px;
		}
		.class-page {
			text-align: left;
			margin-top: 10px;
		}
		.search-item {
			display: inline-block;
			margin-right: 10px;
		}
		.but1 {
			width: 23%;
			/*float: left;*/
			margin-top: 20px;
		}
		.search {
			width: 77%;
			float: right;
			text-align: right;
		}
		.el-button+.el-button {
			margin-left: 0px;
			margin-top: 8px;
		}
	}
</style>